package jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class HomeWordDemo3 {
    public static void main(String[] args) {
        try (Connection conn = DBUtil.getConnection()){
            Statement statement = conn.createStatement();
            String sql = "SELECT username,password,nickname,age "+
                         "FROM user ";
            ResultSet rs = statement.executeQuery(sql);
            while (rs.next()){
                String username = rs.getString("username");
                String password = rs.getString("password");
                String nickname = rs.getString("nickname");
                int age = rs.getInt("age");
                System.out.println(username+","+password+","+nickname+","+age);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
